package com.jt.tenant.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpServer;

import org.json.JSONObject;

/**
 * Created by Administrator on 2016/4/5.
 */
@HttpServer("http://getvin.api.juhe.cn/CarManagerServer/getVINFormat")
public class GetJuHe extends JTAsyGet<GetJuHe.Info>{

    public String key = "f34690bdea4b985ecbac5bbf50411c0f";

    public String VIN ;

    public GetJuHe(String VIN,AsyCallBack<Info> asyCallBack) {

        super(asyCallBack);

        this.VIN = VIN;
    }

    @Override
    protected Info parser(JSONObject object) {

        Info info = new Info();

        JSONObject jsonObject = object.optJSONObject("result");

        JSONObject obj = jsonObject.optJSONObject("body");

        if(object.optString("reason").equals("查询成功") && object.optString("error_code").equals("0")){

            info.CARINFO = obj.optString("CARINFO");

            info.VIN = obj.optString("VIN");

            return info;

       }

        return null;

    }

    public static class Info{

        public String VIN,CARINFO;

    }
}
